package xiegd.study.design;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author: xieguangda
 * @Description:
 * @Date: 2023/11/30 10:01
 */
public class ListTest {

    public static void main(String[] args) {
        List<String> mytest = new ArrayList<>();
        mytest.add("pingguo");
        mytest.add("xueli");

        fiterList(mytest);

        System.out.println(mytest);
    }

    private static void fiterList(List<String> mytest) {
//        mytest = mytest.stream().filter(e-> e.equals("pingguo")).collect(Collectors.toList());
//        System.out.println(mytest);

        Iterator<String> iterator = mytest.iterator();
        while(iterator.hasNext()){
            String element = iterator.next();
            if(element.equals("pingguo")){
                iterator.remove();
            }
        }
    }
}
